package com.example.shiyan2;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Activity2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_2);

        // 返回按钮点击事件监听器
        Button returnButton = findViewById(R.id.returnButton);
        returnButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 在点击返回按钮时显示消息
                Toast.makeText(Activity2.this, "返回按钮被点击", Toast.LENGTH_SHORT).show();
                // 结束当前 Activity，返回上一个 Activity
                finish();
            }
        });
    }
}
